import request from "@/request/";

export const getRoleList = (data) => {
  return request({
    url: "/api/trio-system/role/mes/page",
    method: "post",
    data,
  });
};
export const grantTree = (systemCode) => {
  return request({
    url: "/api/trio-system/menu/grant-tree",
    method: "get",
    params: {
      systemCode,
    },
  });
};

export const grant = (
  roleIds,
  menuIds,
  dataScopeIds = [],
  apiScopeIds = [],
  topMenuIds = []
) => {
  return request({
    url: "/api/trio-system/role/grant",
    method: "post",
    data: {
      roleIds,
      menuIds,
      dataScopeIds,
      apiScopeIds,
      topMenuIds,
    },
  });
};

export const remove = (idList) => {
  return request({
    url: "/api/trio-system/role/mes/remove",
    method: "post",
    data: { idList },
  });
};

export const add = (row) => {
  return request({
    url: "/api/trio-system/role/mes/submit",
    method: "post",
    data: row,
  });
};

export const update = (row) => {
  return request({
    url: "/api/trio-system/role/mes/submit",
    method: "post",
    data: row,
  });
};

export const getRole = (roleIds) => {
  return request({
    url: "/api/trio-system/menu/role-tree-keys",
    method: "get",
    params: {
      roleIds,
    },
  });
};

export const getRoleTree = (tenantId) => {
  return request({
    url: "/api/trio-system/role/tree",
    method: "get",
    params: {
      tenantId,
    },
  });
};

export const getRoleTreeById = (roleId) => {
  return request({
    url: "/api/trio-system/role/tree-by-id",
    method: "get",
    params: {
      roleId,
    },
  });
};

export const getCodeList = (current, size, params) => {
  return request({
    url: "/api/trio-system/system/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
    },
  });
};
